// 格子

import {ecs} from '../framework/assets/libs/ecs/ECS';
import {CellAction, CellEffect, CellStatus, GridSize} from "../cccomponent/enum";
import { Node } from 'cc';

@ecs.register('CellModel')
export class CellModelComponent extends ecs.Comp {
    reset() {
        this.x = 0;
        this.y = 0;
        this.status = CellStatus.common;
        this.type = '';
        this.isSelect = false;
        this.birdType = '';
    }
    // cell 节点
    cellNode: Node;
    // 第几行，第几列的格子
    x: number = 0;
    y: number = 0;
    // 当前格子状态
    status: CellStatus = CellStatus.common;
    // cell 类型
    type: string = '';
    // 鸟消除的类型
    birdType: string = '';
    // 当前是否选中
    isSelect: boolean = false;

    getPositionByXy() {
        const posX = (GridSize.cellWidth + GridSize.offsetX) * (this.y - 0.5);
        const posY = GridSize.gridHeight - (GridSize.offsetY + GridSize.cellHeight ) * (this.x - 0.5);
        return { posX, posY };
    }

    //
    // // 动作延时
    // delay(delayTime: number, callback?: Function) {
    //     this.cmd.push({
    //         action: CellAction.delay,
    //         delayTime,
    //         callback,
    //     })
    // }
}
